﻿using System;
using System.Xml;
using System.Text;
using System.Globalization;

namespace Narwhunderful.Aphelia.Framework.IO.Serialization
{

    internal static class DefaultInitializer
    {

        public static XmlWriterSettings GetXmlWriterSettings()
        {
            return GetXmlWriterSettings(Encoding.UTF8);
        }

        public static XmlWriterSettings GetXmlWriterSettings(Encoding encoding)
        {
            var settings = new XmlWriterSettings();
            settings.Encoding = encoding;
            settings.Indent = true;
            settings.OmitXmlDeclaration = true;
            return settings;
        }

        public static XmlReaderSettings GetXmlReaderSettings()
        {
            var settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;
            return settings;
        }

        public static ITypeNameConverter GetTypeNameConverter()
        {
            return GetTypeNameConverter(false, false, false);
        }

        public static ITypeNameConverter GetTypeNameConverter(bool includeAssemblyVersion, bool includeCulture,
                                                              bool includePublicKeyToken)
        {
            return new TypeNameConverter(includeAssemblyVersion, includeCulture, includePublicKeyToken);
        }

        public static ISimpleValueConverter GetSimpleValueConverter()
        {
            return GetSimpleValueConverter(CultureInfo.InvariantCulture);
        }

        public static ISimpleValueConverter GetSimpleValueConverter(CultureInfo cultureInfo)
        {
            return new SimpleValueConverter(cultureInfo);
        }
    }
}
